<?php

namespace App\Http\Middleware;

use Closure;

class CheckLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    // 第三个参数是传值,$params
    public function handle($request, Closure $next)
    {
        // dump($params);
        // 是否登录
        if(!session()->has('userinfo')){
            return redirect(route('login'))->with('error','请您先登录');
        }
        // 用户防翻墙
        // dump(session()->has('login'));
        // echo '666';
        return $next($request);
    }
}
